]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Add shell_global_focus_stage()
authorOwen Taylor <otaylor@src.gnome.org>
Wed, 19 Nov 2008 19:54:17 +0000 (19:54 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Wed, 19 Nov 2008 19:54:17 +0000 (19:54 +0000)
Add a a method shell_global_focus_stage() to set the
input focus to the stage window, so that Clutter gets
keyboard events.

Adapted from patch in Bug 561299 from Colin Walters

svn path=/trunk/; revision=59

src/shell-global.c
src/shell-global.h

index dde40d981656d86be47d10d4822de7f0ddc0154f..1a186bafebc6b6324613e533a8d8f8edd83ef9ad 100644 (file)
@@ -2,6 +2,9 @@
 
 #include "shell-global.h"
 
+#include "display.h"
+#include <clutter/x11/clutter-x11.h>
+
 struct _ShellGlobal {
   GObject parent;
 
@@ -217,3 +220,21 @@ _shell_global_set_plugin (ShellGlobal  *global,
 
   global->plugin = plugin;
 }
+
+/**
+ * shell_global_focus_stage:
+ *
+ * Set the keyboard focus to the Clutter stage window.  This function
+ * is best used in combination with some sort of visual notification
+ * that the shell has taken over input.
+ */
+void
+shell_global_focus_stage (ShellGlobal *global)
+{
+  MetaScreen *screen = mutter_plugin_get_screen (global->plugin);
+  MetaDisplay *display = meta_screen_get_display (screen);
+  Display *xdisplay = meta_display_get_xdisplay (display);
+  ClutterStage *stage = CLUTTER_STAGE (mutter_plugin_get_stage (global->plugin));
+  Window stagewin = clutter_x11_get_stage_window (stage);
+  XSetInputFocus (xdisplay, stagewin, RevertToParent, CurrentTime);
+}
index f128a2a1e83e100d2b42ab568c993d9090ce66b1..6f59b811d1238f401e6db7847fdc0aef53e88742 100644 (file)
@@ -42,6 +42,10 @@ GList *shell_global_get_windows (ShellGlobal *global);
 void _shell_global_set_plugin (ShellGlobal  *global,
                               MutterPlugin *plugin);
 
+MetaScreen * shell_global_get_screen (ShellGlobal *global);
+
+void shell_global_focus_stage (ShellGlobal *global);
+
 G_END_DECLS
 
 #endif /* __SHELL_GLOBAL_H__ */